﻿#pragma once

#include"Hash.h"

namespace MyHash
{
	template<class K, class V, class Hash = HashFunc<K>>
	class Unodered_map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename Hash_bucket::HashTable<K, pair< K, V>, MapKeyOfT, Hash>::iterator iterator;
		typedef typename Hash_bucket::HashTable<K, pair<const K, V>, MapKeyOfT, Hash>::const_iterator const_iterator;
		
		iterator begin()
		{
			return _mp.begin();
		}

		iterator end()
		{
			return _mp.end();
		}

		const_iterator begin()const
		{
			return _mp.begin();
		}

		const_iterator end()const
		{
			return _mp.end();
		}

		bool insert(const pair<K, V>& key)
		{
			return _mp.Insert(key);
		}
	private:
		Hash_bucket::HashTable<K, pair<const K,V>, MapKeyOfT, Hash> _mp;
	};
	void Test_map()
	{
		Unodered_map<string, string> dict;
		dict.insert(make_pair("sort", ""));
		dict.insert(make_pair("string", "ַ"));
		dict.insert(make_pair("insert", ""));

		for (auto& kv : dict)
		{
			//kv.first += 'x';
			kv.second += 'x';

			cout << kv.first << ":" << kv.second << endl;
		}
		cout << endl;

	}
}